<include file="public@header"/>
<style>
    th,td{
        text-align: center;
    }
</style>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:url('Wuye/payList')}">缴费记录</a></li>
        <li><a href="{:url('Wuye/payAdd')}">添加缴费记录</a></li>
        <li><a href="{:url('Wuye/payCateAdd')}">添加缴费类型</a></li>
    </ul>
    <form id="submitForm" class="well js-ajax-form form-inline margin-top-20" method="post" action="{:url('Wuye/payList')}">
        分类:
        <select class="form-control" name="cate_id" style="width: 140px;">
            <option value="">全部</option>
            <notempty name="cate">
                <volist name="cate" id="cate">
                    <option value='{$cate.id}'>{$cate.name}</option>
                </volist>
            </notempty>
        </select> &nbsp;&nbsp;
        时间:
        <input type="text" class="form-control js-date" name="start_time"
               value="{$start_time|default=''}"
               style="width: 140px;" autocomplete="off">-
        <input type="text" class="form-control js-date" name="end_time"
               value="{$end_time|default=''}"
               style="width: 140px;" autocomplete="off"> &nbsp; &nbsp;
        关键字:
        <input type="text" class="form-control" name="keyword" style="width: 200px;"
               value="{$keyword|default=''}" placeholder="请输入关键字...">
        <input type="submit" class="btn btn-primary" value="搜索"/>
        <a class="btn btn-danger"  href="{:url('Wuye/payList')}" >清空</a>
    </form>
    <form class="js-ajax-form" action="" method="post">
        <button style="margin: 5px;" class="btn btn-danger btn-sm js-ajax-submit" type="submit"
                data-action="{:url('wuye/dels')}" data-subcheck="true" data-msg="您确定删除吗？">
            {:lang('DELETE')}
        </button>
        <input type="hidden" name="table" value="pay">
        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th width="15">
                    <label>
                        <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                    </label>
                </th>
                <notempty name="category">
                    <th width="50">{:lang('SORT')}</th>
                </notempty>
                <th width="200">缴费人</th>
                <th width="200">缴费类型</th>
                <th width="300">缴费简介</th>
                <th width="200">缴费金额</th>
                <th width="200">是否缴费</th>
                <th width="200">缴费时间</th>
                <th width="300">操作</th>
            </tr>
            </thead>
            <notempty name="list">
                <foreach name="list" item="vo">
                    <tr>
                        <td>
                            <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
                                   value="{$vo.id}" title="ID:{$vo.id}">
                        </td>
                        <td>
                            <if condition="$vo.remark eq '' "> {$vo.nickname}
                            <else />  {$vo.remark}
                            </if>
                        </td>
                        <td>
                            <volist name="data" id="voL1">
                                <if condition="($voL1.total eq $vo.total) && ($voL1.time eq $vo.time)">
                                    {$voL1.cate_name},
                                    <elseif  condition="$voL1.id eq $vo.id"/>
                                    {$voL1.cate_name}
                                </if>
                            </volist>
                        </td>
                        <td>{$vo.desc}</td>
                        <td>
                            <notempty name="$vo.total">{$vo.total}
                                <else/>{$vo.num}
                            </notempty>

                        </td>
                        <td>
                            <if condition="$vo.is_pay eq '0' "><a href="javascript:;" onclick="changePay('<volist name="data" id="voL11"><if condition="($voL11.total eq $vo.total) && ($voL11.time eq $vo.time)">{$voL11.id},</if></volist>')">未缴费</a>
                                <else />已缴费
                            </if>
                        </td>
                        <td><?php echo date('Y-m-d H:i',$vo['time'])?></td>
                        <td>
                            &nbsp;<a href="{:url('Wuye/paySend',['openid'=>$vo.openid,'is_pay'=>$vo.is_pay])}">发送通知</a>
                            | <a href='{:url('Wuye/paydetail')}?id=<volist name="data" id="voL11"><if condition="($voL11.total eq $vo.total) && ($voL11.time eq $vo.time)">{$voL11.id},</if></volist>'>明细</a>&nbsp;
                            <?php $adminid = cmf_get_current_admin_id();?>
                            <eq name="adminid" value="1">|<a href="javascript:;" onclick="del('<volist name="data" id="voL12"><if condition="($voL12.total eq $vo.total) && ($voL12.time eq $vo.time)">{$voL12.id},</if></volist>');">删除</a></eq>
                            <eq name="$vo.is_pay" value="0">

                                |
                            <a href='{:url('Wuye/payadd')}?id=<volist name="data" id="voL11"><if condition="($voL11.total eq $vo.total) && ($voL11.time eq $vo.time)">{$voL11.id},</if></volist>'>编辑</a>&nbsp;|
                            <a href="javascript:;" onclick="del('<volist name="data" id="voL12"><if condition="($voL12.total eq $vo.total) && ($voL12.time eq $vo.time)">{$voL12.id},</if></volist>');">删除</a>
                                
                            </eq>

                        </td>
                    </tr>
                </foreach>
            </notempty>
            <tfoot>
            <tr>
                <th width="15">
                    <label>
                        <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                    </label>
                </th>
                <notempty name="category">
                    <th width="50">{:lang('SORT')}</th>
                </notempty>
                <th width="200">缴费人</th>
                <th width="">缴费类型</th>
                <th width="300">缴费简介</th>
                <th width="">缴费金额</th>
                <th width="">是否缴费</th>
                <th width="200">缴费时间</th>
                <th width="300">操作</th>
            </tr>
            </tfoot>
        </table>
        <div class="pagination">{$page|default=''}</div>
    </form>
</div>

<script src="__TMPL__/public/assets/js/jquery-1.10.2.min.js"></script>
<script src="__TMPL__/public/assets/js/layer.js"></script>
<script src="__STATIC__/js/admin.js"></script>
<script>

    function del(id) {
        console.log(id);
        layer.confirm('是否删除？删除之后无法恢复', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.ajax({
                url:"{:url('Wuye/paydel')}",
                data:{'id':id},
                type:"Post",
                dataType:"json",
                success:function(data){
                    layer.msg(data.msg,{icon: 6,time: 1000},function () {
                        location.reload();
                    });
                }
            });
        }, function(){

        });
    }
    function changePay(id) {
        layer.confirm('是否将该用户状态修改为已付款，修改之后无法恢复', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.ajax({
                url:"{:url('Wuye/payChange')}",
                data:{'id':id,'is_pay':'1'},
                type:"Post",
                dataType:"json",
                success:function(data){
                    layer.msg(data.msg,{icon: 6,time: 1000},function () {
                        location.reload();
                    });
                }
            });
        }, function(){

        });
    }
</script>
</body>
</html>